package thread;

import org.junit.Test;

/**
 * @author: feiwang_6
 * @create: 2019/12/3 18:56
 * @description:
 */
public class SynchronizedDemo {
    
    private String lock = "lock";
    
    @Test
    public void syncTest() throws InterruptedException {
        synchronized (lock){
            System.out.println("111111111111");
            lock.wait();
            System.out.println("222222222222");
        }
    }
    
    @Test
    public void testMethod() throws InterruptedException {
        Thread[] threads = new MyThread[50];
        for(int i = 0; i < 50; i++){
            threads[i] = new MyThread();
        }
        for(Thread m : threads){
            m.start();
        }
        
        for(Thread m : threads){
            m.join();
        }
    }
}
